package com.tencent.mlvb.apilive;

import java.util.LinkedList;
    import java.util.List;
    import android.app.Activity;
    import android.app.Application;

public class ExitApplication extends Application {
        private List<Activity> activityList = new LinkedList<>();
        private static ExitApplication instance;
        private ExitApplication() {}
        public static ExitApplication getInstance() {
            if (instance == null) {
                instance = new ExitApplication();
            }
            return instance;
        }
        // 添加Activity到管理列表
        public void addActivity(Activity activity) {
            activityList.add(activity);
        }
        // 退出应用程序，清理所有Activity
        public void exit() {
            for (Activity activity : activityList) {
                if (activity != null) {
                    activity.finish();
                }
            }
            System.exit(0);
        }
    }